import java.util.Scanner;
import java.util.Arrays;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: jingziyou
 * Date: 2023-03-09
 * Time: 10:50
 */
public class Test {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[][] a = new int[n][m];
        int[][] b = new int[n][m];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                a[i][j] = sc.nextInt();
            }
        }
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                b[i][j] = sc.nextInt();
            }
        }
        if(is_equal(a,b,n))
            System.out.println("Yes");
        else
            System.out.println("No");
    }

    public static boolean is_equal(int[][] a, int[][] b, int n) {
        for (int i = 0; i < n; i++) {
            if (Arrays.equals(a[i], b[i])) {
            } else
                return false;
        }
        return true;
    }
}
